feat(work): WorkForm + Rule/RuleSet — slim re-cut of work system (R2-1)#1386
Conversation
#1189 work scope) Introduces lionagi/work/ as a greenfield module with WorkForm, FieldSpec, Rule, RuleSet — the validated core of the work system without the engine or CLI layers. 106 new tests, all green against an 8527-test full suite. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
CRITICAL: remove false ReDoS thread-timeout protection (GIL blocks join; daemon thread burns CPU regardless). Replace with honest doc + tight 4096-char input cap. REGEX_MATCH_TIMEOUT removed from public API. HIGH: validate_form/fill_form accept optional ruleset= kwarg. Rules run after coercion; failures set status=error with errors in validation_errors. validate_form without ruleset is unchanged. MEDIUM: WorkForm and FieldSpec now inherit from Element, gaining UUID id, created_at, and metadata consistent with lionagi ecosystem. form_id becomes a str property alias over str(self.id). LOW: FieldSpec rejects incompatible default at construction time (new model_validator). RuleSet.add raises ValueError on duplicate rule_id. Tests: 135 work tests (was 106), 8556 total passed (zero regressions). New tests cover Element identity, default validation, ruleset integration, duplicate-id prevention, bool-as-int behaviour (pinned), length cap, and REGEX_MATCH_TIMEOUT absence assertion. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Round 2 Review: lionagi/work module (PR #1386)SummaryThe fixes in this round successfully address the critical safety and architectural issues identified in Round 1. The dangerously misleading ReDoS "protection" has been replaced with honest documentation and sensible input limits. The Verification of Claimed Fixes1. ReDoS "Theater" Removal [FIXED]
2. FormStatus and RuleSet Integration [FIXED]
3. Element Pattern Alignment [FIXED]
4. FieldSpec Default Validation [FIXED]
5. RuleSet Duplicate Prevention [FIXED]
6. Bool-as-Int Behavior [VERIFIED]
Findings & Suggestions[Minor] Serialization of
|
Summary
This PR is the R2-1 slim re-cut of the work system, superseding the
lionagi/work/scope from draft PRs #1231 and #1189. Those drafts are stale intent-references only — this PR is grounded entirely onmain.What's Kept vs. Cut
WorkForm+FieldSpecRule+RuleSetfill_form/validate_formWorkEngine/worker.pydefinition.pycleanup.py,charter.py)Design Choices vs. Drafts
multiprocessing.Process(pickling issues on macOSspawn). Replaced withthreading.Thread(daemon=True)— same timeout guarantee, no subprocess overhead, pickling not required.definition.py: the scope requirement explicitly said "include only if WorkForm genuinely needs it" — it doesn't.BaseModel. The draft predated recent refactors; forcing Element/Node inheritance would couple an engine-free primitive to the full protocol stack for no gain.LOC Count
lionagi/work/__init__.pylionagi/work/form.pylionagi/work/rules.pytests/work/test_work_forms_rules.pySource is well under the 700 LOC target.
Test Evidence
Supersedes the
lionagi/work/scope of #1231 and #1189. Does not merge the engine, worker, or CLI changes from those drafts.🤖 Generated with Claude Code
Co-authored-by: Claude Fable 5 noreply@anthropic.com